package com.gdteam.kernel.timer.impl;

import com.gdteam.kernel.timer.TimerJob;

public abstract class AbstractTimerJob implements TimerJob {
    
    private boolean suspended = false;
    
    //Default value of delay is 0 ms
    private Long delay = Long.valueOf(0);
    private Long period = null;
    
    public void setPeriod(Long period) {
        this.period = period;
    }
    
    public void setDelay(Long delay) {
        this.delay = delay;
    }
    
    public Long getDelay() {
        return this.delay;
    }

    public Long getPeriod() {
        return this.period;
    }

    public boolean isSuspended() {
        return this.synchronizedIsSuspended();
    }

    public void resume() {
        this.synchronizedResume();
    }

    public void suspend() {
        this.synchronizedSuspend();
    }
    
    private synchronized void synchronizedResume() {
        this.suspended = false;
    }
    
    private synchronized void synchronizedSuspend() {
        this.suspended = true;
    }
    
    private synchronized boolean synchronizedIsSuspended() {
        return this.suspended;
    }

}
